//
//  InfoListGridsGroupsCell.swift
//  AmountBody
//
//  Created by Qiu Jishuai on 2018/1/23.
//  Copyright © 2018年 RCMTM. All rights reserved.
//

import UIKit

class InfoListFormCell: UITableViewCell {

    lazy var formView: JSFormView = {
        let formView = JSFormView()
        formView.contentView.cornerRadius = 8
        return formView
    }()

    override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
        return formView.intrinsicContentSize
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setup()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }

    private func setup() {
        contentView.addSubview(formView)
        formView.mas_makeConstraints { (make) in
            make?.edges.equalTo()(contentView)
        }
    }
}

//extension UIView {
//    private static var screenOrientationContext: Void?
//    var cacheScreenOrientation: UIDeviceOrientation {
//        get {
//            var value = objc_getAssociatedObject(self, &UIView.screenOrientationContext)as? Int
//            if value == nil {
//                value = UIScreen.main.bounds.width > UIScreen.main.bounds.height ? 0 : 1
//            }
//            return UIDeviceOrientation(rawValue: value!)!
//        }
//        set {
//            objc_setAssociatedObject(self, &UIView.screenOrientationContext, newValue.rawValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
//        }
//    }
//}

